<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="utfpr.sistemaestagios.*" %>
<%@ page import="utfpr.sistemaestagios.types.*" %>
<%@ page import="utfpr.sistemaestagios.dao.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%

DAOCoordenador dao = SistemaEstagios.getFactory().getDAOCoordenador();

boolean flag_tried = false;
boolean flag_success = false;

String login = request.getParameter("login");
String senha = request.getParameter("password");
String nome = request.getParameter("name");

if (login != null && senha != null && nome != null) {
	flag_tried = true;
	Coordenador coordenador = new Coordenador();
	coordenador.codigoCurso = login;
	coordenador.nomeCurso = nome;
	coordenador.senha = senha;
	flag_success = dao.insert(coordenador) != null;
}

%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link href="../data/style.css" rel="stylesheet" type="text/css" />
<title>Root :: Cadastrar Coordenador</title>
</head>
<body>
<jsp:include page="../META-INF/page_start.txt" flush="true" />
<jsp:include page="../META-INF/menu_coordenador.jsp" flush="true" />
<jsp:include page="../META-INF/page_middle.txt" flush="true" />

<h1>Registrar Coordenador</h1>
<%
if (flag_tried) {
if (flag_success) {
%>
<div>Coordenador cadastrado com sucesso!</div>
<%
} else {
%>
<div>Coordenador nao foi cadastrado!</div>
<%
}
}
%>
<form>
<table>
<tr>
<td style="text-align: right;"><b>Codigo de curso:</b></td>
<td><input type="text" name="login" /></td>
</tr>
<tr>
<td style="text-align: right;"><b>Nome do curso:</b></td>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<td style="text-align: right;"><b>Senha:</b></td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td colspan="2" style="text-align: right;">
<input type="submit" value="Ok">
</td>
</tr>
</table>
</form>

<jsp:include page="../META-INF/page_end.txt" flush="true" />
</body>
</html>